using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class StartUI : MonoBehaviour
{

    public Button StartGame;
    public Button GameSetting;
    public Button GameExit;
    public GameObject Game;

    public AudioSource audios;
    private void Awake()
    {
        MsgSignal.AddListener<bool>(EventConst.StartUI, IsShowPanel);
    }

    private void IsShowPanel(bool show)
    {
        this.gameObject.SetActive(show);
    }

    void Start()
    {
        StartGame.onClick.AddListener(() => {
            GetComponent<AudioSource>().Play();
            IsShowPanel(false);
            Game.SetActive(true);
            MsgSignal.Dispatch(EventConst.MainUI, true);

        });
        GameSetting.onClick.AddListener(() => {
            GetComponent<AudioSource>().Play();
            MsgSignal.Dispatch(EventConst.SettingPanel, true);
        });
        GameExit.onClick.AddListener(() => {
            GetComponent<AudioSource>().Play();
#if UNITY_EDITOR
            UnityEditor.EditorApplication.isPlaying = false;
#else
        Application.Quit();
#endif
        });
    }
    private void OnDestroy()
    {
        MsgSignal.RemoveListener<bool>(EventConst.StartUI, IsShowPanel);
    }
}
